package com.wjbgn.bsolver.server.enums;

/**
 * 排序字段枚举
 *
 * @author wjbgn
 * @date 2022/04/19 15:54
 **/
public enum SortEnum {
    CREATE_TIME("latest","createTime"),
    VIEWS("views","views"),
    ANSWERS("answers","answers");

    public String getField() {
        return field;
    }

    public String getCode() {
        return code;
    }

    private String field;
    private String code;

    SortEnum(String code, String field) {
        this.code = code;
        this.field = field;
    }

    public static String getField(String code) {
        for (SortEnum value : SortEnum.values()) {
            if (code.equals(value.getCode())){
                return value.getField();
            }
        }
        return null;
    }
}
